<template>
  <div class="project">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper"></div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
<!--      <el-button  size="small" class="addBtn" type="primary" :disabled="state != 1 && state != 4 " @click="handleAdd">新增</el-button>-->
      <el-button  size="small" class="addBtn" type="primary" :disabled="state != 1 && state != 4 " @click="handleBatchAdd">新增</el-button>
    </div>
    <el-table border
        v-loading="loading"
        size="small"
        :data="dataSource"
        :header-cell-style="{background:'#eef1f6',color:'#606266'}"
        :default-sort = "{prop: 'inDate', order: 'descending'}">
      <el-table-column prop="name" label="资产名称" sortable></el-table-column>
      <el-table-column prop="model" label="规格型号" width="200" sortable></el-table-column>
      <el-table-column prop="price" label="单价（元）" sortable></el-table-column>
      <el-table-column prop="unit" label="计量单位" sortable></el-table-column>

      <el-table-column prop="buyer" label="购买单位" sortable></el-table-column>
      <el-table-column width="100" prop="isFixed" label="固定资产" sortable>
        <template slot-scope="scope">
          {{scope.row.isFixed ? "是":"否"}}
        </template>
      </el-table-column>
      <el-table-column  width="100" prop="isFax" label="是否含税" sortable>
        <template slot-scope="scope">
          {{scope.row.isFixed ? "是":"否"}}
        </template>
      </el-table-column>
      <el-table-column prop="manufacturer" label="供应商" sortable></el-table-column>
      <el-table-column prop="usefulLife" label="使用期限" sortable></el-table-column>
      <el-table-column fixed="right" label="操作" width="150">
          <template slot-scope="scope">
            <div v-if="state == 1 || state == 4" >
              <el-button @click="handleEdit(scope.row)" type="text">编辑</el-button>
              <el-popconfirm
                title="确定删除吗？"
                placement="top-start"
                @onConfirm="handleDelete(scope.row.id)">
                <el-button  slot="reference"  type="text">删除</el-button>
              </el-popconfirm>
            </div>
            <div v-else>
              <el-button @click="handleDetail(scope.row)" type="text">查看</el-button>
            </div>
          </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination
      :total="ipagination.total"
      :page.sync="ipagination.current"
      :limit.sync="ipagination.pageSize"
      @pagination="loadData"
    ></pagination>
    <asset-modal ref="modalForm" @ok="modalFormOk"></asset-modal>
  </div>
</template>

<script>
  /* eslint-disable */
  import { SingleTableMixins } from '@/mixins/SingleTableMixins'
  import Pagination from '@/components/Pagination'
  import AssetModal from '../modules/AssetModal'


  export default {
    mixins: [ SingleTableMixins ],
    components: {AssetModal, Pagination},
    name: "detail",
    data () {
      return{
          disableMixinCreated:true,
          state:1,
          url:{
            list: "/instoreage/itemList",
            delete: "/instoreage/deleteItem",
          }
      }
    },
    created () {

    },
    methods: {
      handleBatchAdd(){
        this.$refs.modalForm.add(this.queryParam.mainId,true);
        this.$refs.modalForm.title = "批量新增资产明细";
      },
      getDataByMain(id,row) {
          this.queryParam.mainId = id;
          this.state = row.state;
          this.loadData(1);
      },
      handleAdd: function () {
        this.$refs.modalForm.add(this.queryParam.mainId);
        this.$refs.modalForm.title = "新增资产明细";
      },
    }
  }
</script>

<style scoped>

</style>
